package day06;

import java.util.Arrays;

public class BubleSort {
    public static void main(String[] args) {
        int[] num = {12,25,76,19,1,4};
        // 34,2,56,12,67,45
        // 2,34,56,12,67,45
        //2,34,12,56,67,45
        //2,34,12,56,45,67

        //2,34,12,56,45,67
        //2,12,34,56,45,67
        //2,12,34,45,56,67

        for (int i = 0; i < num.length; i++) {
            System.out.println("第"+i+"轮开始");
            for (int j = 0; j < num.length-1-i; j++) {
                if (num[j] > num[j+1]) {
                    int tmp = num[j+1];
                    num[j+1] = num[j];
                    num[j] = tmp;
                }
                System.out.println("第"+j+"次排序结果"+Arrays.toString(num));
            }
        }
        System.out.println(Arrays.toString(num));
    }
}
